using CNRegex.Entity;
using NHibernate.Linq;
using System.Linq;
using CNRegex.Entity.EntityEx;
using Project.Common;
using System;
using System.Collections.Generic;
using NHibernate;
namespace CNRegex.Dal.DataAccess {
	public partial class DalRegexUserBlogComment 
	{
		private void Initialize()
		{

		}
		public IList<RegexUserBlogCommentEx> List(int? pageSize, int? pageIndex, Guid blogID, ref int count)
		{
			pageSize = pageSize ?? ProjectGlobal.PAGE_SIZE;
			var query = (from t1 in Session.Query<RegexUserBlogComment>()
						 join t2 in Session.Query<RegexUser>()
						 on t1.UserID equals t2.ID
						 orderby t1.CommentDate descending
						 where t1.UserBlogID == blogID
						 select new RegexUserBlogCommentEx()
						 {
							 ID = t1.ID,
							 RegexUserName = t2.Name,
							 UserID = t1.UserID,
							 Comment = t1.Comment,
							 CommentDate = t1.CommentDate,
							 UserBlogID = t1.UserBlogID
						 }).Skip((pageIndex ?? 0) * pageSize.Value).Take(pageSize.Value);
			count = (from t1 in Session.Query<RegexUserBlogComment>()
					 orderby t1.CommentDate descending
					 where t1.UserBlogID == blogID
					 select t1.ID).Count();
			return query.ToList();
		}
	}
}
		